package com.mavenq.fly.business.controller;

import com.mavenq.fly.annotation.Retry;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

@RestController
@RequestMapping(value = "retry")
public class RetryController {

    @RequestMapping("/test")
    @Retry(retryPeriod = 10000L)
    public Object retry(Integer num) {
        Random random = new Random();
        int i = random.nextInt(10);
        System.out.println(i);
        if (i < 5) {
            throw new RuntimeException();
        }
        return i;
    }
}
